unit Unit28; 

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, sqldb, db,
  DbCtrls, StdCtrls, Unit1;

type

  { TForm28 }

  TForm28 = class(TForm)
    Button1: TButton;
    Datasource1: TDatasource;
    DBComboBox1: TDBComboBox;
    Label1: TLabel;
    SQLQuery1: TSQLQuery;
    procedure Button1Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    procedure FormShow(Sender: TObject);
  private
    { private declarations }
  public
    proveedor : String;
  end; 

var
  Form28: TForm28; 

implementation

{ TForm28 }

procedure TForm28.FormShow(Sender: TObject);
begin
  proveedor := '';
  if SQLQuery1.Active = True then
    SQLQuery1.Close;

  SQLQuery1.DataBase := Form1.PQConnection1;
  SQLQuery1.Transaction := Form1.SQLTransaction1;
  SQLQuery1.SQL.Text := 'select prv_nombre from proveedor order by prv_nombre';

  SQLQuery1.Open;
  DBComboBox1.DataField := 'prv_nombre';

  DBComboBox1.Clear;
  
  while not SQLQuery1.EOF do
  begin
    DBComboBox1.Items.Add(SQLQuery1.Fields[0].AsString);
    SQLQuery1.Next;
  end;
  
  DBComboBox1.Text := '';
end;

procedure TForm28.Button1Click(Sender: TObject);
begin
  proveedor := DBComboBox1.Text;
  Close;
end;

procedure TForm28.FormClose(Sender: TObject; var CloseAction: TCloseAction);
begin
  if SQLQuery1.Active = True then
    SQLQuery1.Close;
end;

initialization
  {$I unit28.lrs}

end.

